'use strict';
/** @type {import('sequelize-cli').Migration} */
module.exports = {
    async up(queryInterface, Sequelize) {
        await queryInterface.createTable('Users', {
            id: {
                allowNull: false,
                autoIncrement: true,
                primaryKey: true,
                type: Sequelize.INTEGER.UNSIGNED
            },
            email: {
                type: Sequelize.STRING
            },
            username: {
                type: Sequelize.STRING
            },
            password: {
                type: Sequelize.STRING
            },
            nickname: {
                type: Sequelize.STRING
            },
            sex: {
                type: Sequelize.TINYINT
            },
            avatar:Sequelize.STRING,//头像地址
            parentId:Sequelize.INTEGER,//部门ID
            remark:Sequelize.STRING,
            rolesId:Sequelize.STRING,//权限ID
            roles:Sequelize.STRING,//权限名
            phone:Sequelize.STRING,//电话
            status:Sequelize.INTEGER,//启用状态
            createdAt: {
                allowNull: false,
                type: Sequelize.DATE
            },
            updatedAt: {
                allowNull: false,
                type: Sequelize.DATE
            },
        });
        await queryInterface.addIndex(
            'Users', {
                fields: ['email'],//要索引的字段
                unique: true //唯一索引
            });
        await queryInterface.addIndex(
            'Users', {
                fields: ['username'],
                unique: true
            });
    },
    async down(queryInterface, Sequelize) {
        await queryInterface.dropTable('Users');
    }
};